/*!
 * \file frdb_add_metadata_info.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include <frdb_cursor.h>

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    Sql_statement *p_st_statement = NULL;
    int i_type = FRDB_BIND;
    Sql_metadata_info *p_st_metadata = NULL;
    int i_ret = 0;

    p_st_statement = (Sql_statement *)frmalloc(sizeof(Sql_statement));
    memset(p_st_statement, 0x00, sizeof(Sql_statement));

    p_st_metadata = (Sql_metadata_info *)frmalloc(sizeof(Sql_metadata_info));
    memset(p_st_metadata, 0x00, sizeof(Sql_metadata_info));

    i_ret = frdb_add_metadata_info(p_st_statement, i_type, p_st_metadata);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frdb_statement_free(&p_st_statement);

    return;

}

static void __case2(void)
{
    Sql_statement *p_st_statement = NULL;
    int i_type = FRDB_COLUMN;
    Sql_metadata_info *p_st_metadata = NULL;
    int i_ret = 0;

    p_st_statement = (Sql_statement *)frmalloc(sizeof(Sql_statement));
    memset(p_st_statement, 0x00, sizeof(Sql_statement));

    p_st_metadata = (Sql_metadata_info *)frmalloc(sizeof(Sql_metadata_info));
    memset(p_st_metadata, 0x00, sizeof(Sql_metadata_info));

    i_ret = frdb_add_metadata_info(p_st_statement, i_type, p_st_metadata);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frdb_statement_free(&p_st_statement);

    return;

}

static void __case3(void)
{
    Sql_statement *p_st_statement = NULL;
    int i_type = FRDB_DEFINE;
    Sql_metadata_info *p_st_metadata = NULL;
    int i_ret = 0;

    p_st_statement = (Sql_statement *)frmalloc(sizeof(Sql_statement));
    memset(p_st_statement, 0x00, sizeof(Sql_statement));

    p_st_metadata = (Sql_metadata_info *)frmalloc(sizeof(Sql_metadata_info));
    memset(p_st_metadata, 0x00, sizeof(Sql_metadata_info));

    i_ret = frdb_add_metadata_info(p_st_statement, i_type, p_st_metadata);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frdb_statement_free(&p_st_statement);

    return;

}


int add_suite_frdb_add_metadata_info(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frdb_cursor frdb_add_metadata_info()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);

    return FR_SUCC;
}
